<?php 
namespace App\Infra;

use App\Utils\ModelOperatorUtil;
use App\Models\CaseType;
use App\Models\Level;
use App\Models\Role;
use App\Models\Sets;

class AdminManager{

	use ModelOperatorUtil;

	public function getAllCaseTypes($conditions = null){
		return $this->findModel(CaseType::class,CaseType::query(),$conditions,$first = true) ->get();
	}

	public function createCaseType($data){
		$this->create(CaseType::class,$data);
	}

	public function updateCaseType($id,$data){
		$caseType = CaseType::find($id);

		$this->update(CaseType::class,$id,$data);

		return $caseType;
	}

	public function deleteCaseType($id){
		$caseType = CaseType::find($id);

		$caseType->delete();

		return $caseType;
	}

	public function getLevels($conditions = null){
		return $this->findModel(level::class,level::query(),$conditions,$first = true) ->get();
	}

	public function createLevel($data){
		$this->create(Level::class,$data);
	}

	public function updateLevel($id,$data){
		$level = level::find($id);

		$this->update(level::class,$id,$data);

		return $level;
	}

	public function deleteLevel($id){
		$level = level::find($id);

		$level->delete();

		return $level;
	}


	public function getRoles(){
		return Role::all();
	}

	public function getSet(){
		return Sets::find(1);
	}

	public function updateSet($data){
		Sets::find(1)->update($data);
	}
}